<template>
  <div class="head-container">
    <!-- 搜索 -->
    <div v-show="sup_this.searchToggle">
      <el-input v-model="paramBean.key" clearable placeholder="输入关键词搜索" style="width: 200px;" class="filter-item" @keyup.enter.native="sup_this.toQuery"/>
      <el-button class="filter-item" size="mini" type="success" icon="el-icon-search" @click="sup_this.toQuery">搜索</el-button>
      <el-button class="filter-item" size="mini" type="warning" icon="el-icon-refresh-left" @click="sup_this.resetQuery()">重置</el-button>
    </div>
    <div class="crud-opts">
      <el-button
        v-permission="['SYS_ADMIN']"
        :loading="deleteAllLoading"
        type="danger"
        size="mini"
        class="filter-item"
        icon="el-icon-delete"
        @click="deleteAll">清空缓存</el-button>
      <DataGridOpts :sup_this="sup_this" @refreshClick="refreshClick" @searchClick="searchClick" />
    </div>
  </div>
</template>

<script>
import { delAll } from '@/api/system/redis'

export default {
  components: { },
  props: {
    paramBean: {
      type: Object,
      required: true
    },
    sup_this: {
      type: Object,
      required: true
    }
  },
  data() {
    return {
      deleteAllLoading: false
    }
  },
  methods: {
    refreshClick() {
      this.sup_this.init()
    },
    searchClick() {
      this.sup_this.toggleSearch()
    },
    beforeCreate() {
    },
    deleteAll() {
      this.deleteAllLoading = true
      const data = { idList: ['*'] }
      delAll(data).then(res => {
        this.sup_thist.init()
        this.deleteAllLoading = false
      }).catch(err => {
        this.deleteAllLoading = false
        console.log(err)
      })
    }
  }
}
</script>
